#include "openfile.h"

OpenFile::OpenFile(QString dirVideo) : videoName(dirVideo){}

ImageList OpenFile::startLoad()
{
    // ImageList : containts all images
    ImageList imageList;

    // Open the video file and read it by frame
    VideoCapture capture(videoName.toStdString().c_str());
    if(!capture.isOpened())
    {
        qDebug() << "Ouverture du flux vidéo impossible !";
    }
    else
    {
        Mat imageBRG(480, 640, 16);
        Mat imageRGB(480, 640, 16);
        // Create an Image for a loaded frame
        while(capture.read(imageBRG))
        {
            cvtColor(imageBRG, imageRGB, CV_BGR2RGB);
            Image newimage(imageRGB);
            imageList.addImage(newimage);
        }
    }
    return imageList;
}
